package hotciv.standard;

import hotciv.framework.GameConstants;
import hotciv.framework.Player;
import hotciv.framework.Unit;

/** Standard implementation of a unit. */

public class StandardUnit implements Unit 
{
	protected String type;
	protected Player owner;
	protected int moveCount;
  
	public StandardUnit(String type, Player owner) 
	{
		this.type = type;
		this.owner = owner;
		moveCount = 1;
	}
  
	@Override
	public Player getOwner() 
	{
		return owner;
	}

	@Override
	public int getMoveCount() 
	{
		return moveCount;
	}

	public void decrementMoveCount() 
	{
		moveCount--;
	}
	
	public void resetMoveCount() 
	{
		moveCount = 1;
	}
  
	@Override
	public int getAttackingStrength() 
	{
		if(type==GameConstants.ARCHER)
		{
			return GameConstants.archerAttack;
		}
		if(type==GameConstants.LEGION)
		{
			return GameConstants.legionAttack;
		}
		if(type==GameConstants.SETTLER)
		{
			return GameConstants.settlerAttack;
		}
		return 0;
	}

	@Override
	public int getDefensiveStrength() 
	{
		if(type==GameConstants.ARCHER)
		{
			return GameConstants.archerDefense;
		}
		if(type==GameConstants.LEGION)
		{
			return GameConstants.legionDefense;
		}
		if(type==GameConstants.SETTLER)
		{
			return GameConstants.settlerDefense;
		}
		return 0;
	}

	@Override
	public String getTypeString() 
	{
		return type;
	}
}
